﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bmz.Laboratory.DesignPattern
{
    class SimpleFactory
    {
        public interface people
        {
            void say();
        }


        public class chinese : people
        {
            public void say()
            {
                Console.WriteLine("说中国话");
            }
        }


        public class american : people
        {
            public void say()
            {
                Console.WriteLine("speak english");
            }
        }

        public class peopleFactory
        {
            public static people create(int type)
            {
                if (type == 1)
                {
                    return new chinese();
                }
                else
                {
                    return new american();
                }
            }
        }

        public class test
        {
            public static void main(String[] args)
            {
                people p = peopleFactory.create(1);
                p.say();
                p = peopleFactory.create(2);
                p.say();
            }
        }
    }
}
